package com.kfc.platform.user.service.impl;


import org.springframework.beans.factory.annotation.Autowired;

import com.kfc.platform.user.dao.UserDao;
import com.kfc.platform.user.domain.User;
import com.kfc.platform.user.service.UserService;

public class UserServiceImpl implements UserService{
	private UserDao userDao;
	
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public UserDao getUserDao() {
		return userDao;
	}

	@Override
	public String createUser(User user) {
		String str = null;
		User insertUser = new User();
		insertUser.setUsername(user.getUsername());
		insertUser.setPassword(user.getPassword());
		insertUser.setEmail(user.getEmail());
		insertUser.setDate(user.getDate());
		insertUser.setPhonenum(user.getPhonenum());
		if(user == null){
			System.out.println("user不能为空！");
		}
		try{
		userDao.save(insertUser);
		str =  "插入数据库成功！";}
		catch(Exception e){
			str = "插入数据库失败！";
		}finally{
			return str;
		}
	}

	@Override
	public void deleteUser(User user) {
		// TODO Auto-generated method stub
		userDao.delete(user);
	}

}
